.magic-shelf-container {
  width: 75rem;
  max-width: 75rem;
  display: flex;
  flex-direction: column;

  @media (max-width: 1280px) {
    width: 100%;
    max-width: 100%;
  }
}

.panel-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1.25rem 1.5rem;
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);

  .header-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    border-radius: 10px;


    .header-icon {
      font-size: 1.5rem;
      color: var(--primary-contrast-color);
    }
  }

  .header-text {
    flex: 1;

    .panel-title {
      margin: 0 0 0.25rem 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--text-color);
    }

    .panel-description {
      margin: 0;
      font-size: 0.875rem;
      color: var(--text-secondary-color);
    }
  }

  ::ng-deep .close-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
  }

  @media (max-width: 480px) {
    padding: 1rem;

    .header-icon-wrapper {
      width: 40px;
      height: 40px;

      .header-icon {
        font-size: 1.25rem;
      }
    }

    .header-text {
      .panel-title {
        font-size: 1.125rem;
      }

      .panel-description {
        font-size: 0.8rem;
      }
    }

    ::ng-deep .close-button {
      top: 0.5rem;
      right: 0.5rem;

      .p-button {
        width: 2rem;
        height: 2rem;
      }
    }
  }
}

.magic-shelf-content {
  padding: 2rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-bottom: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  min-height: 450px;

  @media (max-width: 480px) {
    padding: 1rem;
    min-height: 350px;
  }
}

.form-header {
  margin-bottom: 0.75rem;
  display: flex;
  width: 100%;
  gap: 1rem;
  padding: 1rem;
  background: var(--overlay-background);
  border-radius: 8px;
  border: 1px solid var(--border-color);

  @media (max-width: 768px) {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.form-field {
  flex: 1;

  label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
  }

  input {
    width: 100%;
  }
}

.icon-picker-section {
  display: flex;
  align-items: flex-end;

  .icon-picker-wrapper {
    label {
      display: block;
      margin-bottom: 0.5rem;
      font-weight: 600;
      color: var(--text-color);
      font-size: 0.9rem;
    }

    .icon-display-container {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.625rem 1rem;
      border: 1px solid var(--border-color);
      border-radius: 6px;
      cursor: pointer;
      transition: all 0.2s ease;
      background: var(--card-background);

      &:hover {
        border-color: var(--primary-color);
      }

      .selected-icon {
        flex-shrink: 0;
      }

      .icon-label {
        font-size: 0.95rem;
        color: var(--text-secondary-color);
        white-space: nowrap;
      }

      .icon-placeholder {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: var(--text-secondary-color);

        i {
          font-size: 1.125rem;
          color: var(--primary-color)
        }

        span {
          font-size: 0.875rem;
        }
      }
    }
  }

  @media (max-width: 768px) {
    align-items: flex-start;
  }
}

.public-checkbox-section {
  display: flex;
  align-items: flex-end;

  .checkbox-wrapper {
    display: flex;
    align-items: center;
    padding: 0.625rem 0;

    label {
      margin-left: 0.5rem;
      font-weight: 500;
      color: var(--text-color);
      cursor: pointer;
    }
  }

  @media (max-width: 768px) {
    align-items: flex-start;

    .checkbox-wrapper {
      padding: 0.5rem 0;
    }
  }
}

.rules-container {
  overflow: auto;
  max-height: 40rem;
  padding: 0.5rem;

  @media (max-width: 768px) {
    max-height: 35rem;
  }

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: var(--overlay-background);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
    transition: background 0.2s ease;

    &:hover {
      background: var(--primary-color);
    }
  }
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);

  .footer-actions {
    display: flex;
    gap: 0.75rem;
  }

  @media (max-width: 480px) {
    padding: 1rem;
    gap: 0.5rem;

    .footer-actions {
      width: 100%;
      justify-content: flex-end;
      gap: 0.5rem;
    }
  }
}

.save-button-section {
  margin: 1.5rem 0 0 0;
  padding: 1rem;
  background: var(--overlay-background);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.group-container {
  padding: 1rem;
  border-left: 4px solid var(--primary-color);
  margin-top: 0.75rem;
  width: 100%;
  border-radius: 8px;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  transition: all 0.3s ease;

  &:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  }

  @media (max-width: 768px) {
    padding: 0.75rem;
  }
}

.group-header {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;

  label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
  }

  .condition-select {
    width: 9rem;
  }

  @media (max-width: 640px) {
    gap: 0.5rem;

    .condition-select {
      width: 100%;
      max-width: 9rem;
    }
  }
}

.rule-item {
  margin-left: 1rem;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  padding: 0.125rem;
  gap: 0.75rem;
  background: var(--overlay-background);
  transition: all 0.2s ease;

  .field-select,
  .operator-select {
    min-width: 14rem;
  }

  .value-input,
  .autocomplete-wrapper {
    width: 100%;
  }

  @media (max-width: 1024px) {
    flex-wrap: wrap;
    margin-left: 0.5rem;
    gap: 0.5rem;

    .field-select,
    .operator-select {
      min-width: 12rem;
      flex: 1;
    }

    .value-input,
    .autocomplete-wrapper {
      flex: 1;
      min-width: 200px;
    }
  }

  @media (max-width: 640px) {
    margin-left: 0;
    padding: 0.5rem;

    .field-select,
    .operator-select {
      min-width: 100%;
    }
  }
}
